#include "cc.h"
#include "bsp_clk.h"
#include "bsp_led.h"
#include "bsp_delay.h"
#include "bsp_beep.h"
#include "bsp_gpio.h"
#include "bsp_key.h"
#include "bsp_int.h"
#include "bsp_exti.h"
#include "bsp_epittimer.h"
#include "bsp_keyfilter.h"
#include "bsp_delay.h"
#include "bsp_uart.h"
#include "stdio.h"


char *banner = 	"========================================================\r\n"
				"正点原子I.MX6ULL ALPHA/Mini开发板Linux驱动之ARM逻辑开发\r\n" \
				"--Date: 	2024/05/21\r\n" \
				"--Author: 	ChenHaoxu, Dimon.chen, 11813202388@qq.com\r\n" \
				"========================================================\r\n";



int main(void)
{

	static uint8_t led_state = OFF;
	// static uint8_t beep_state = OFF;

	int_init();			/* 中断初始化 */
	imx6u_clkinit();	/* 时钟主频初始化，PLL1, PLL2, PLL3 */
	clk_init();			/* 使能所有外设时钟 */
	led_init();			/* led gpio 初始化 */
	beep_init();		/* beep gpio 初始化 */
	//key_init();			/* key gpio 初始化 */
	exti_init();		/* gpio外设中断初始化 */

	//epittimer_init(0, 0, 33000000);	/* EPIT分频frac=0 1分频，EPIT1时钟源66MHz，EPIT1->LR加载值计数器=33MHz，定时周期为500ms */
	//epittimer_init(1, 0, 66000000/20);	/* EPIT分频frac=0 1分频，EPIT1时钟源66MHz，EPIT1->LR加载值计数器=33MHz，定时周期为1000/20=50ms */

	keyfilter_init();
	delay_init();
	uart_init();		/* UART初始化 */


	led_switch(LED_0, ON);


	beep_switch(ON);
	delay(200);
	beep_switch(OFF);
	delay(200);
	beep_switch(ON);
	delay(200);
	beep_switch(OFF);

	printf("%s", banner);

	unsigned int a = 10;

    while(1){
		led_state = !led_state;
		led_switch(LED_0, led_state);

		printf("Hello World\r\n");
		printf("a=%d hex=%x\r\n", a, a);

		scanf("%u", &a);
    }

    return 0;
}